package com.hst.capacity.application.jpush.model.request;


import com.alibaba.fastjson2.JSONObject;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

@Setter
public class JPushNotificationAndroid extends JPushNotification {

    private String title;
    private String builderId;
    private String channelId;
    private String category;
    private int priority=0;
    private int style=0;
    private int alertType=0;
    private String bigText;
    private JSONObject inbox;
    private String bigPicPath;
    private JSONObject extras;
    private String largeIcon;
    private String smallIconUri;
    private JSONObject intent;
    private String uriActivity;
    private String uriAction;
    private int badgeAddNum=0;
    private int badgeSetNum=-1;
    private String badgeClass;
    private String sound;
    private String showBeginTime;
    private String showEndTime;
    private String displayForeground;


    @Override
    public JSONObject getParam() {
        JSONObject param=new JSONObject();

        JSONObject jsonObject=new JSONObject();

        if(StringUtils.isBlank(getAlert())){
            return null;
        }

        jsonObject.put("alert",this.getAlert());

        if(StringUtils.isNotBlank(title)){jsonObject.put("title",title);}
        if(StringUtils.isNotBlank(builderId)){jsonObject.put("builder_id",builderId);}
        if(StringUtils.isNotBlank(channelId)){jsonObject.put("channel_id",channelId);}
        if(StringUtils.isNotBlank(category)){jsonObject.put("category",category);}
        if(priority!=0){jsonObject.put("priority",priority);}
        if(style!=0){jsonObject.put("style",style);}
        if(alertType!=0){jsonObject.put("alert_type",alertType);}
        if(StringUtils.isNotBlank(bigText)){jsonObject.put("big_text",bigText);}
        if(inbox!=null){jsonObject.put("inbox",inbox);}
        if(StringUtils.isNotBlank(bigPicPath)){jsonObject.put("big_pic_path",bigPicPath);}
        if(extras!=null){jsonObject.put("extras",extras);}
        if(StringUtils.isNotBlank(largeIcon)){jsonObject.put("large_icon",largeIcon);}
        if(StringUtils.isNotBlank(smallIconUri)){jsonObject.put("small_icon_uri",smallIconUri);}
        if(intent!=null){jsonObject.put("intent",intent);}
        if(StringUtils.isNotBlank(uriActivity)){jsonObject.put("uri_activity",uriActivity);}
        if(StringUtils.isNotBlank(uriAction)){jsonObject.put("uri_action",uriAction);}
        if(badgeAddNum!=0){jsonObject.put("badge_add_num",badgeAddNum);}
        if(badgeSetNum!=-1){jsonObject.put("badge_set_num",badgeSetNum);}
        if(StringUtils.isNotBlank(badgeClass)){jsonObject.put("badge_class",badgeClass);}
        if(StringUtils.isNotBlank(sound)){jsonObject.put("sound",sound);}
        if(StringUtils.isNotBlank(showBeginTime)){jsonObject.put("show_begin_time",showBeginTime);}
        if(StringUtils.isNotBlank(showEndTime)){jsonObject.put("show_end_time",showEndTime);}
        if(StringUtils.isNotBlank(displayForeground)){jsonObject.put("display_foreground",displayForeground);}

        param.put("notification",jsonObject);
        return param;
    }

}
